using UnityEngine;
using System.Collections;

//Ewww gross inheritance, but I want a callback and don't want to set up message passing.
public class Damagable : Animatable {

    public int totalHP = 1;
    public int currentHP = 1;

    public bool isDamagable = true;

	// Use this for initialization
	void Start () {
        currentHP = totalHP;
	}

    public virtual void DoDamage(int damage)
    {
        if (!isDamagable) return;
        currentHP -= damage;
        damage = Mathf.Max(currentHP, 0);
        if (damage <= 0)
        {
            Die();
        }
    }

    protected virtual void Die()
    {
        Destroy(gameObject);
    }
}
